from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
# 启动Edge浏览器
driver = webdriver.Edge()
# 打开Edge设置页面
driver.get("edge://settings/system")
# 等待页面加载
time.sleep(2)

# 关闭“启动增强”
try:
    startup_boost_checkbox = driver.find_element(By.CSS_SELECTOR, "input#startupBoostEnabled")
    if startup_boost_checkbox.is_selected():
        startup_boost_checkbox.click()
        print("已关闭启动增强")
except Exception as e:
    print(f"关闭启动增强时发生错误：{e}")

# 关闭“在Microsoft Edge关闭后继续运行后台扩展和应用”
try:
    background_mode_checkbox = driver.find_element(By.CSS_SELECTOR, "input#backgroundModeEnabled")
    if background_mode_checkbox.is_selected():
        background_mode_checkbox.click()
        print("已关闭后台扩展和应用")
except Exception as e:
    print(f"关闭后台扩展和应用时发生错误：{e}")

# 关闭浏览器
driver.quit()
